<?php
/**
 * @project     : Thuynga
 * @copyright   : 
 * @desc        : Thuc hien cac thao tac tren bang category
 * @coder       : Hoang Van Lac
 * @createdate  : 2/11/2011
*/
class Category_model extends CI_Model
{
    
  var $category_type =0;                
  var $category_parent=0;               
  var $category_name_vi='';                
  var $category_name_en ='';           
  var $category_status =1;    
    /**
     * 
     * Constructor
     * 
     */
    function __construct()
    {
        parent::__construct();
    }

    function get_by_type($type, $status = 1)
    {
        if($status!=-1)
        {
            $this->db->where('category_status', $status);
        }
        $this->db->where('category_type',$type);
        $query=$this->db->get('category');
        return $query->result();
    }

    function get_by_id($id)
    {
        $this->db->where('category_id', $id);
        $query = $this->db->get('category');
        return $query->row();
    }
    function get_by_parent($parent)
    {
        $this->db->where('category_parent', $parent);
        $query = $this->db->get('category');
        return $query->result();
    }   
    function get_all($status=1)
    {
        if($status!=-1)
        {
            $this->db->where('category_status',$status);
        }
        $query = $this->db->get('category');
        return $query->result();
    }      
}
